package comparators;

public class TestObject implements Comparable<TestObject> {

	
	public String name;
	public int sortingNumber;
	
	public TestObject(String name, int sortingNumber){
		this.name = name;
		this.sortingNumber = sortingNumber;
	}
	@Override
	public String toString() {
		return name;
	}
	
	/**
	 * needed to avoid duplicates in set ( #see equals()) also 
	 */
	@Override
	public int hashCode() {
		return name.hashCode();
	}
	
	/**
	 * needed to avoid duplicates in set ( #see hashCode()) also 
	 */
	@Override
	public boolean equals(Object obj) {
		return this.name.equals(((TestObject)obj).name);
	}
	
	/**
	 * needed for sorting
	 */
	@Override
	public int compareTo(TestObject o) {
		return sortingNumber-o.sortingNumber;
	}
}
